﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace DiIoc.ScriptableObjectDemo
{
    [CreateAssetMenu(fileName = "New Game Event", menuName = "Game Event", order = 52)] // 1
    public class GameEvents : ScriptableObject
    {
        public List<GameEventListener> listeners = new List<GameEventListener>();

        public void Raise()
        {
            for (int i = listeners.Count-1; i >=0; i--)
            {
                listeners[i].OnEventRaised();
            }
        }

        public void RegisterListener(GameEventListener listener) // 7
        {
            listeners.Add(listener);
        }

        public void UnregisterListener(GameEventListener listener) // 8
        {
            listeners.Remove(listener);
        }
    }
}

